﻿using System.Collections.Generic;

namespace PrearrangedChaos.AgileZen.Service.Rest
{
    internal class RestArguments
    {
        public int? PageSize { get; private set; }
        public int? CurrentPage { get; set; }
        public string Enrichments { get { return string.Join(",", this._enrichments); } }
        public string Filter { get; set; }
        public int? ProjectId { get; private set; }
        public int? StoryId { get; private set; }
        public int? RoleId { get; private set; }
        private List<string> _enrichments = new List<string>();

        private RestArguments()
        {
            CurrentPage = 1;
        }

        public void AddEnrichment(string enrichment)
        {
            if (!this._enrichments.Contains(enrichment))
                this._enrichments.Add(enrichment);
        }

        public static RestArguments Attachment(int projectId, int storyId, int pageSize = 0)
        {
            return new RestArguments() { ProjectId = projectId, StoryId = storyId, PageSize = pageSize};
        }

        public static RestArguments Comment(int projectId, int storyId, int pageSize = 0)
        {
            return new RestArguments() { ProjectId = projectId, StoryId = storyId, PageSize = pageSize };
        }

        public static RestArguments Invite(int projectId, int pageSize = 0)
        {
            return new RestArguments() { ProjectId = projectId, PageSize = pageSize };
        }

        public static RestArguments Phase(int projectId, int pageSize = 0)
        {
            return new RestArguments() { ProjectId = projectId, PageSize = pageSize };
        }

        public static RestArguments Project(int pageSize = 0)
        {
            return new RestArguments() { PageSize = pageSize };
        }

        public static RestArguments Role(int projectId, int pageSize = 0)
        {
            return new RestArguments() { ProjectId = projectId, PageSize = pageSize };
        }

        public static RestArguments Story(int projectId = 0, int tagId = 0, string tag = null, int pageSize = 0)
        {
            return new RestArguments() { ProjectId = projectId, PageSize = pageSize };
        }

        public static RestArguments Tag(int projectId, int storyId = 0, int pageSize = 0)
        {
            return new RestArguments() { ProjectId = projectId, StoryId = storyId, PageSize = pageSize };
        }

        public static RestArguments Task(int projectId, int storyId = 0, int pageSize = 0)
        {
            return new RestArguments() { ProjectId = projectId, StoryId = storyId, PageSize = pageSize };
        }

        public static RestArguments User(int projectId, int roleId = 0, int pageSize = 0)
        {
            return new RestArguments() { ProjectId = projectId, RoleId = roleId, PageSize = pageSize };
        }
    }
}